package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.annotation.log.WebLog;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.service.BWorkPlanService;
import top.tangyh.lamp.care.entity.BWorkPlan;
import top.tangyh.lamp.care.vo.query.DeleteBactchQuery;
import top.tangyh.lamp.care.vo.query.WorkPlanDetailQueryVO;
import top.tangyh.lamp.care.vo.query.WorkPlanQueryVO;
import top.tangyh.lamp.care.vo.result.PageOutputDTO;
import top.tangyh.lamp.care.vo.result.WorkPlanDetailOutVO;
import top.tangyh.lamp.care.vo.result.WorkPlanOutVO;
import top.tangyh.lamp.care.vo.save.BWorkPlanSaveVO;
import top.tangyh.lamp.care.vo.save.WorkPlanInVO;


import java.util.List;

/**
 * <p>
 * 前端控制器
 * 全局的排班表
 * </p>
 *
 * @author zqb
 * @date 2024-07-18 15:42:26
 * @create [2024-07-18 15:42:26] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/work_plan")
@Tag(name = "全局的排班管理")
public class BWorkPlanController {
//    extends SuperController<BWorkPlanService, Long, BWorkPlan
//            , BWorkPlanSaveVO, BWorkPlanUpdateVO, BWorkPlanPageQuery, BWorkPlanResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }

    private final BWorkPlanService bWorkPlanService;

    @Operation(summary = "分页查询排班", description = "分页查询排班")
    @WebLog("分页查询排班")
    @GetMapping("/page")
    public R<PageOutputDTO<WorkPlanOutVO>> query(WorkPlanQueryVO queryVO) {
        PageOutputDTO<WorkPlanOutVO> pageResult = bWorkPlanService.selectPageByQuery(queryVO);
        return R.success(pageResult);
    }

    @Operation(summary = "查询排班时间轴", description = "查询排班时间轴")
    @WebLog("查询排班时间轴")
    @GetMapping("/select/detail")
    public R<List<WorkPlanDetailOutVO>> queryDetail(WorkPlanDetailQueryVO queryVO) {

        List<WorkPlanDetailOutVO> resultList = bWorkPlanService.selectDetailListByQuery(queryVO);
        return R.success(resultList);
    }


    @Operation(summary = "添加排班", description = "添加排班")
    @WebLog("添加排班")
    @PostMapping("/add")
    public R add(@RequestBody WorkPlanInVO inVO) {
        bWorkPlanService.add(inVO);
        return R.success();
    }

    @Operation(summary = "修改排班", description = "修改排班")
    @WebLog("修改排班")
    @PutMapping("/update")
    public R update(@RequestBody  WorkPlanInVO inVO) {
        bWorkPlanService.update(inVO);
        return R.success();
    }

    @Operation(summary = "批量删除排班", description = "批量删除排班")
    @WebLog("批量删除排班")
    @DeleteMapping("/deleteBatch")
    public R delete(   @RequestBody  DeleteBactchQuery deleteBactchQuery ) {
        bWorkPlanService.delete(deleteBactchQuery.getIds());
        return R.success();
    }


}


